<?php
if (!defined('ROOT_PATH')) die('No direct access.');
function view_co($id){
	view_header_top();
	$user = getUser($id);
	//----------------------------------------------------------------
	$title = "Realita - Checkout";
	$content = "Realita - Checkout";
	$url = MARKETPLACE_URL;
	$image = IMAGE_URL."300x240.gif";	//profpic orangnya / tokonya
	$desc = "Profil orangnya : ".$user['bio'];
	$auth = "RealiTA";
	$qwords = "profil, marketplace, umkm".$user['nama'];
	//----------------------
	echo "<title>$title</title>";
	//<!--META DATA Open Graph-->
	echo "<meta property=\"og:title\" content=\"$title\"/>";
	echo "<meta property=\"og:type\" content=\"$content\"/>";
	echo "<meta property=\"og:url\" content=\"$url\"/>";
	echo "<meta property=\"og:image\" content=\"$image\"/>";
	echo "<meta property=\"og:site_name\" content=\"RealiTA UMKM\"/>";
	echo "<meta property=\"og:description\" content=\"$desc\" />";
	//<!--META DATA FB-->
	echo "<meta property=\"fb:app_id\" content=\"147346958657510\" />";
	//<!--META DATA-->
	echo "<meta name=\"author\" content=\"$auth\" />";
	echo "<meta name=\"keywords\" content=\"$qwords\" />";
	echo "<meta name=\"description\" content=\"$desc\" />";
	echo "<meta name=\"robots\" content=\"ALL\" />";
	echo "<meta charset=\"UTF-8\" />";
	//----------------------------------------------------------------
	view_header_bottom();
?>
	<div class="row">    
		<div class="large-12 columns">		  
			<h3><?php echo $_SESSION['logged']['name']; ?></h3>
			  <p><a href="<?php echo PROFIL_URL."keranjang" ?>">&laquo; keranjang</a></p>
			  <h4>Alamat</h4>
				<div class="row">
					<div class="large-3 columns">
						<select>
							<option>Profil</option>
							<option>Alamat 1</option>
						</select>
					</div>
				</div>
				<div class="row">
					<div class="large-12 columns">
					<form class="custom" method="post" action="<? echo HOME_URL."transaksi/fin" ?>">	
						<div class="row">
							<div class="large-4 columns">
								<label>Penerima</label>
								<input type="text" name="nama-penerima" placeholder="Nama penerima..." value="<?php echo $user['nama']?>">
							  </div>
						</div>
						<div class="row">
							<div class="large-3 columns">
								<label>Nomor Kontak</label>
								<input type="text" name="no-penerima" placeholder="Nomor penerima..." value="<?php echo $user['kontak']?>">
							  </div>
						</div>
						<div class="row">
							<div class="large-3 columns">
								<label>Kota</label>
								<input type="text" name="kota" placeholder="Nama kota..." value="<?php echo $user['kota']?>">
							  </div>
						</div>
						<div class="row">
							<div class="large-6 columns">
								<label>Alamat Lengkap</label>
								<textarea name="alamat" placeholder="alamat lengkap toko..."><?php echo $user['alamat']?></textarea>
							  </div>
						</div>
						<div class="row">
							<div class="large-6 columns">
								<div onclick="javascript:$('#co').show();" class="button tiny">Set</div>
							</div>
						</div>
					</div>
				</div>
			  <h4>Checkout</h4>
			  <div class="row">
			   <?php
				echo "<div id='co' class='large-12 columns' style='display:none'><table class='tabel-keranjang'><thead>";
				echo '<tr class="judul-keranjang"><th>Produk</th><th>Qty</th><th>Toko</th><th>Kota</th><th>Keterangan</th><th>Nominal</th><th>Metode</th><th>Biaya</th><th>Sub-Total</th></tr></thead>';
				$total = 0;
				echo '<tbody>';
				foreach ($_SESSION['keranjang'] as $key=>$keranjang) {
					echo "<tr>";
					$barang = getBarang($keranjang['id']);
					echo "<td class='produk'><a href=\"".BARANG_URL."a/".$barang['idBarang']."/".$barang['slug-nama']."\">".$barang['nama']."</a></td>";
					echo "<td>".$keranjang['kuantitas']."</td>";
					$user = getUserId($barang['idPenjual']);
					echo "<td class='toko'><a href=\"".TOKO_URL."a/".$user['idFB']."/".$user['slug_nama-toko']."\">".$user['nama-toko']."</a></td>";
					echo "<td>".$user['kota']."</td>";
					echo '<td>'.$ket = $barang['preorder']==1 ? 'pre-order' : '-'.'</td>';
					$sub = ((int)$keranjang['kuantitas']*(int)$barang['harga']);
					echo '<td class="nominal">'.int_to_rp($sub).'</td>';
					echo "<td><select name=\"metode\"><option value=\"1\">Transfer</option><option value=\"2\">COD</option></select></td>";
					$kirim = (15000)*($barang['berat']/1000);
					echo '<td class="nominal">'.int_to_rp($kirim).'</td>';
					echo "<input type=\"hidden\" name=\"kirim-$key\" value=\"$kirim\">";
					$sub += $kirim;
					echo '<td class="nominal">'.int_to_rp($sub).'</td>';
					$total += $sub;
					echo "</tr>";
				}
				echo '<tr><td colspan="8"><strong>TOTAL</strong></td><td>'.int_to_rp($total).'</td></tr>';
				echo "<input type=\"hidden\" name=\"total\" value=\"$total\"";
				echo "</tbody></table>";
			   ?>
			   <h5>Diskon</h5>
			   <div class="row">
				   <div class="large-10 columns">
						<p>Poin : <?php echo $user['poin_reward']?></p>
						<div class="row">
							<div class="large-3 columns">
								<select name="diskon">
									<option value="0"></option>
									<option value="10000">Diskon 1</option>
									<option value="25000">Diskon 2</option>
								</select>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="large-3 push-7 columns">
						<input class="button" type="submit" value="Finalisasi">
					</div>
				</div>
			</div>
		</div>
	</div>
    <!-- End Content -->
<?php
	view_footer();
}
?>
